package com.epam.cdp.selenium2.core.ui;

import java.util.Map;

import com.epam.cdp.selenium2.core.ui.locators_map.ElementInfoContainer;
import com.epam.cdp.selenium2.core.ui.locators_map.ObjectMapReader;

/**
 * @author akhachaturan
 * 
 */
public class Screen
{

  protected ObjectMapReader reader;

  private final Map<String, ElementInfoContainer> OBJECTS_MAP;

  {
    reader = new ObjectMapReader( this.getClass() );
    OBJECTS_MAP = reader.readElementsMap();
  }

  /**
   * Method for search elements in ObjectsMap. <br>
   * <font color='#ff0000'>DON'T USE THIS METHOD FOR ELEMENTS WHICH ARE DESCRIBED BY XPATTERN. USE METHOD
   * <b>byXpattern(String, String[])</b></font>
   * 
   * @param elementName
   * @return
   * @author akhachaturan
   */
  protected ElementInfoContainer fromMap( String elementName )
  {
    return OBJECTS_MAP.get( elementName );
  }

  /**
   * METHOD FOR SEARCH PATTERN FOR ELEMENT AND PROVIDE MASSIVE OF STRING FOR COMPOSE FULL XPATH
   * 
   * @param elementName
   * @param composite
   * @return
   * @author akhachaturan
   */
  protected ElementInfoContainer byXpattern( String elementName, String[] composite )
  {
    ElementInfoContainer container = OBJECTS_MAP.get( elementName );
    container.setComposite( composite );
    return container;
  }

}
